﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CityIT.Sales.Entities;
using System.Data;
using System.Data.SqlClient;

namespace CityIT.Sales.SqlServer
{
    public class Sys_Menu
    {
        private string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlServer"].ToString();

        public DataSet QueryMenus(int ParentRowID, int UserID)
        {
            DataSet ds = new DataSet();
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "Proc_QueryMenus";
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter parameter = new SqlParameter("@ParentID", ParentRowID);
                parameter.Size = 4;
                parameter.SqlDbType = SqlDbType.Int;
                parameter.Direction = ParameterDirection.Input;
                cmd.Parameters.Add(parameter);

                parameter = new SqlParameter("@UserID", UserID);
                parameter.Size = 4;
                parameter.SqlDbType = SqlDbType.Int;
                parameter.Direction = ParameterDirection.Input;
                cmd.Parameters.Add(parameter);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                adapter.Fill(ds, "Menu");
                cmd.Dispose();
                conn.Close();
            }
            return ds;
        }
    }
}
